﻿using System.IO;
using UnityEngine;

public class GameDataWriter {
    BinaryWriter writer;

    public GameDataWriter (BinaryWriter writer) {
        this.writer = writer;
    }

    public void Write (int value) {
        writer.Write (value);
    }

    public void Write (float value) {
        writer.Write (value);
    }

    public void Write (Vector3 value) {
        writer.Write (value.x);
        writer.Write (value.y);
        writer.Write (value.z);
    }
    public void Write (Quaternion value) {
        writer.Write (value.x);
        writer.Write (value.y);
        writer.Write (value.z);
        writer.Write (value.w);
    }
}

public class GameDataRead {

    BinaryReader reader;
    public GameDataRead (BinaryReader read) {
        reader = read;
    }

    public float ReadFloat () {
        return reader.ReadSingle ();
    }

    public int ReadInt () {
        return reader.ReadInt32 ();
    }

    public Vector3 ReadVector3 () {
        var vect = new Vector3 ();
        vect.x = ReadFloat ();
        vect.y = ReadFloat ();
        vect.z = ReadFloat ();
        return vect;
    }
    public Quaternion ReadQueaterion () {
        var qua = new Quaternion ();
        qua.x = ReadFloat ();
        qua.y = ReadFloat ();
        qua.z = ReadFloat ();
        qua.w = ReadFloat ();
        return qua;
    }

}